package com.akk.action;


import com.akk.config.annotation.IgnoreAuth;
import com.akk.module.app.entity.AppBanner;
import com.akk.module.app.service.AppBannerService;
import com.akk.module.app.service.AppSharePicService;
import com.akk.utils.RestResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/app/banner")
@Api(value = "web-banner",description = "BANNER")
public class BannerAction {

    @Autowired
    private AppBannerService bannerService;

    @Autowired
    private AppSharePicService sharePicService;

    @IgnoreAuth
    @RequestMapping("/get")
    @ApiOperation(value = "获取APP的Banner图",notes = "获取APP的Banner图",httpMethod = "GET",response = RestResponse.class)
    public RestResponse banners(@ApiParam(value = "APPID",required = true)@RequestParam String appId){
        Map tags = bannerService.appBanner(appId);
        return RestResponse.build(tags);
    }

    @IgnoreAuth
    @RequestMapping("/tag")
    @ApiOperation(value = "获取APP的指定分类Banner图",notes = "获取APP的指定分类Banner图",httpMethod = "GET",response = RestResponse.class)
    public RestResponse bannerByTag(@ApiParam(value = "APPID",required = true)@RequestParam String appId,@ApiParam(value = "标签分类",required = true)@RequestParam String tag){
        Map params = new HashMap();
        params.put("appId",appId);
        params.put("bannerTag",tag);
        List<AppBanner> list = bannerService.findByParam(params);
        return RestResponse.build(list);
    }

    @IgnoreAuth
    @RequestMapping("/share")
    @ApiOperation(value = "获取APP的分享图",notes = "获取APP的分享图",httpMethod = "GET",response = RestResponse.class)
    public RestResponse sharePics(@ApiParam(value = "APPID",required = true)@RequestParam String appId){
        return RestResponse.build(sharePicService.sharePicByAppId(appId));
    }

}
